﻿<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40">
	<xsl:output method="html" indent="no" encoding="utf-8"/>
	<xsl:template match="AppGridE">
		<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40">
			<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
				<Author>深圳市明源软件股份有限公司</Author>
				<LastAuthor>深圳市明源软件股份有限公司</LastAuthor>
				<Company>深圳市明源软件股份有限公司</Company>
				<Version>1.1</Version>
			</DocumentProperties>
			<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
				<WindowHeight>7590</WindowHeight>
				<WindowWidth>13800</WindowWidth>
				<WindowTopX>240</WindowTopX>
				<WindowTopY>75</WindowTopY>
				<ProtectStructure>False</ProtectStructure>
				<ProtectWindows>False</ProtectWindows>
			</ExcelWorkbook>
			
			<xsl:call-template name="Styles" />
			
			<Worksheet ss:Name="sheet1">
				<Table x:FullColumns="1" x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="14">
					<xsl:attribute name="ss:ExpandedColumnCount">
						<xsl:choose>
							<xsl:when test="RowInfo/Serial/@serialtype=0">
								<xsl:value-of select="RowInfo/Serial/Row[@type='-1']/@count+RowInfo/Serial/Row[@type='1']/@count"/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="RowInfo/Serial/Row[@type='-1']/@count+RowInfo/Serial/Row[@type='1']/@count+1"/>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:attribute>
					<xsl:attribute name="ss:ExpandedRowCount">
						<xsl:value-of select="TitleInfo/@rowcount+RowData/@rowcount"/>
					</xsl:attribute>
					<xsl:choose>
						<xsl:when test="RowInfo/Serial/@serialtype=1">
							<Column ss:AutoFitWidth="0" ss:Width="30"/>
						</xsl:when>
					</xsl:choose>
					<xsl:for-each select="RowInfo/Row/Cell">
						<Column ss:AutoFitWidth="0" ss:Width="100"/>
					</xsl:for-each>
					<xsl:call-template name="Titles"/>
					
					<xsl:apply-templates select="RowData/Row" />
					<Row>
						<Cell ss:StyleID="sTip">
							<Data ss:Type="String">
								<xsl:text></xsl:text>
							</Data>
						</Cell>
					</Row>
					<Row>
						<Cell ss:StyleID="sTip">
							<Data ss:Type="String">
								<xsl:text></xsl:text>
							</Data>
						</Cell>
					</Row>
					<Row>
						<Cell ss:StyleID="sTip">
							<Data ss:Type="String">
								<xsl:text>注意:</xsl:text>
							</Data>
						</Cell>
					</Row>
					<Row>
						<Cell ss:StyleID="sTip">
							<Data ss:Type="String">
								<xsl:text>    1.每个费项下如果不存在合约规划的都会自带一个空的合约规划.</xsl:text>
							</Data>
						</Cell>
					</Row>
					<Row>
						<Cell ss:StyleID="sTip">
							<Data ss:Type="String">
								<xsl:text>    2.如果要新增合约规划,可以选中合约规划下面一行,然后插入或者复制一条合约规划到指定地方插入.</xsl:text>
							</Data>
						</Cell>
					</Row>
					<Row>
						<Cell ss:StyleID="sTip">
							<Data ss:Type="String">
								<xsl:text>    3.如果没有录入"合约规划名称(B列)",则认为是一个空行,系统会忽略此行.</xsl:text>
							</Data>
						</Cell>
					</Row>
					<Row>
						<Cell ss:StyleID="sTip">
							<Data ss:Type="String">
								<xsl:text>    4.费项只能修改"是否末级费项(F列)"为"是"的行的"目标成本(</xsl:text>
								<xsl:value-of select="/CustomControl/ExportCost/@name" />
								<xsl:text>)(G列)"的值,父级金额会自动同步;"备注(H列)"为可选填列;其它均不能修改.</xsl:text>
							</Data>
						</Cell>
					</Row>
					<Row>
						<Cell ss:StyleID="sTip">
							<Data ss:Type="String">
								<xsl:text>    5.一个合法的合约规划需要录入("合约规划名称(B列)","合约规划金额(C列)","类别(D列)","级数(E列)"),缺一不可,"备注(H列)"为非必填列.</xsl:text>
							</Data>
						</Cell>
					</Row>
					<Row>
						<Cell ss:StyleID="sTip">
							<Data ss:Type="String">
								<xsl:text>    6.如果合约规划存在层级关系,请设置好对应的级数,否则导入会提示级数设置错误.</xsl:text>
							</Data>
						</Cell>
					</Row>
					<Row>
						<Cell ss:StyleID="sTip">
							<Data ss:Type="String">
								<xsl:text>    7.调整完成后,请将文件另存为Excel标准格式,否则导入会提示格式不正确.</xsl:text>
							</Data>
						</Cell>
					</Row>
				</Table>
				<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
					<Print>
						<ValidPrinterInfo/>
						<PaperSizeIndex>9</PaperSizeIndex>
						<HorizontalResolution>200</HorizontalResolution>
						<VerticalResolution>200</VerticalResolution>
					</Print>
					<Selected/>
					<Panes>
						<Pane>
							<Number>3</Number>
							<ActiveRow>1</ActiveRow>
							<ActiveCol>4</ActiveCol>
						</Pane>
					</Panes>
					<ProtectObjects>False</ProtectObjects>
					<ProtectScenarios>False</ProtectScenarios>
				</WorksheetOptions>
			</Worksheet>
		</Workbook>
	</xsl:template>
	
	<xsl:template name="Styles" match="/AppGridEx/AppGridE/RowInfo">
		<Styles>
			<Style ss:ID="Default" ss:Name="Normal">
				<Alignment ss:Vertical="Center"/>
				<Borders/>
				<Font ss:FontName="宋体" x:CharSet="134" ss:Size="10" ss:Color="#000000"/>
				<Interior/>
				<NumberFormat/>
				<Protection/>
			</Style>
			<Style ss:ID="sTitle">
				<Alignment ss:Horizontal="Center" ss:Vertical="Center"/>
				<Font ss:FontName="宋体" x:CharSet="134" ss:Size="12" ss:Bold="1"/>
			</Style>
			<xsl:for-each select="Row/Cell">
				<Style>
					<xsl:attribute name="ss:ID">s<xsl:value-of select="position()"/></xsl:attribute>
					<Alignment ss:Vertical="Center">
						<xsl:attribute name="ss:Horizontal"><xsl:value-of select="@align"/></xsl:attribute>
					</Alignment>
					<Font ss:FontName="宋体" x:CharSet="134" ss:Size="10"/>
					<xsl:choose>
						<xsl:when test="@celltype=3 or @celltype=4">
							<NumberFormat>
								<xsl:attribute name="ss:Format"><xsl:value-of select="@format"/></xsl:attribute>
							</NumberFormat>
						</xsl:when>
						<xsl:when test="@celltype=7">
							<xsl:choose>
								<xsl:when test="@format!=''">
									<NumberFormat>
										<xsl:attribute name="ss:Format"><xsl:value-of select="@format"/></xsl:attribute>
									</NumberFormat>
								</xsl:when>
							</xsl:choose>
						</xsl:when>
					</xsl:choose>
				</Style>
			</xsl:for-each>
		</Styles>
	</xsl:template>
	
	<xsl:template name="Titles" match="AppGridE/TitleInfo">
		<xsl:for-each select="Titles/Title">
			<Row ss:Height="20">
		</xsl:for-each>
		<Row ss:Height="30">
			<Cell ss:StyleID="sTitle">
				<Data ss:Type="String">
					<xsl:text>费项编码</xsl:text>
				</Data>
			</Cell>
			<Cell ss:StyleID="sTitle">
				<Data ss:Type="String">
					<xsl:text>费项名称/合约规划名称</xsl:text>
				</Data>
			</Cell>
			<Cell ss:StyleID="sTitle">
				<Data ss:Type="String">
					<xsl:text>合约规划金额</xsl:text>
				</Data>
			</Cell>
			<Cell ss:StyleID="sTitle">
				<Data ss:Type="String">
					<xsl:text>类别</xsl:text>
				</Data>
			</Cell>
			<Cell ss:StyleID="sTitle">
				<Data ss:Type="String">
					<xsl:text>级数</xsl:text>
				</Data>
			</Cell>
			<Cell ss:StyleID="sTitle">
				<Data ss:Type="String">
					<xsl:text>是否末级费项</xsl:text>
				</Data>
			</Cell>
			<Cell ss:StyleID="sTitle">
				<Data ss:Type="String">
					<xsl:text>目标成本(</xsl:text>
					<xsl:value-of select="/CustomControl/ExportCost/@name" />
					<xsl:text>)</xsl:text>
				</Data>
			</Cell>
			<Cell ss:StyleID="sTitle">
				<Data ss:Type="String">
					<xsl:text>备注</xsl:text>
				</Data>
			</Cell>
		</Row>
	</xsl:template>
	
	<xsl:template match="Row">
		<xsl:choose>
			<xsl:when test="@isend='1'"><!--最末级费项-->
				<Row>
					<Cell ss:StyleID="s1End">
						<Data ss:Type="String">
							<xsl:value-of select="@costcode"/>
						</Data>
					</Cell>
					<Cell ss:StyleID="s2End">
						<Data ss:Type="String">
							<xsl:value-of select="@costshortname"/>
						</Data>
					</Cell>
					<Cell ss:StyleID="s3End">
						<Data ss:Type="String"/>
					</Cell>
					<Cell ss:StyleID="s4End">
						<Data ss:Type="String">
							<xsl:text>费项</xsl:text>
						</Data>
					</Cell>
					<Cell ss:StyleID="s5End">
						<Data ss:Type="Number">
							<xsl:value-of select="@costlevel"/>
						</Data>
					</Cell>
					<Cell ss:StyleID="s6End">
						<Data ss:Type="String">
							<xsl:text>是</xsl:text>
						</Data>
					</Cell>
					<Cell ss:StyleID="s7End">
						<Data ss:Type="Number">
							<xsl:value-of select="@targetcost"/>
						</Data>
					</Cell>
					<Cell ss:StyleID="s8End">
						<Data ss:Type="String">
							<xsl:value-of select="@remarks"/>
						</Data>
					</Cell>
				</Row>
			</xsl:when>
			<xsl:when test="@isend='0'"><!--非末级费项-->
				<Row>
					<Cell ss:StyleID="s1NotEnd">
						<Data ss:Type="String">
							<xsl:value-of select="@costcode"/>
						</Data>
					</Cell>
					<Cell ss:StyleID="s2NotEnd">
						<Data ss:Type="String">
							<xsl:value-of select="@costshortname"/>
						</Data>
					</Cell>
					<Cell ss:StyleID="s3NotEnd">
						<Data ss:Type="String"/>
					</Cell>
					<Cell ss:StyleID="s4NotEnd">
						<Data ss:Type="String">
							<xsl:text>费项</xsl:text>
						</Data>
					</Cell>
					<Cell ss:StyleID="s5NotEnd">
						<Data ss:Type="Number">
							<xsl:value-of select="@costlevel"/>
						</Data>
					</Cell>
					<Cell ss:StyleID="s6NotEnd">
						<Data ss:Type="String">
							<xsl:text>否</xsl:text>
						</Data>
					</Cell>
					<Cell ss:StyleID="s7NotEnd">
						<xsl:attribute name="ss:Formula">
							<xsl:value-of select="@refrow"/>
						</xsl:attribute>
						<Data ss:Type="Number">
							<xsl:value-of select="@targetcost"/>
						</Data>
					</Cell>
					<Cell ss:StyleID="s8NotEnd">
						<Data ss:Type="String">
							<xsl:value-of select="@remarks"/>
						</Data>
					</Cell>
				</Row>
			</xsl:when>
			<xsl:otherwise><!--合约规划-->
				<Row>
					<Cell ss:StyleID="s1Budget">
						<Data ss:Type="String"/>
					</Cell>
					<Cell ss:StyleID="s2Budget">
						<Data ss:Type="String">
							<xsl:value-of select="@costshortname"/>
						</Data>
					</Cell>
					<Cell ss:StyleID="s3Budget">
						<Data ss:Type="Number">
							<xsl:value-of select="@targetcost"/>
						</Data>
					</Cell>
					<Cell ss:StyleID="s4Budget">
						<Data ss:Type="String">
							<xsl:text>合约规划</xsl:text>
						</Data>
					</Cell>
					<Cell ss:StyleID="s5Budget">
						<Data ss:Type="Number">
							<xsl:value-of select="@costlevel"/>
						</Data>
					</Cell>
					<Cell ss:StyleID="s6Budget">
						<Data ss:Type="String"/>
					</Cell>
					<Cell ss:StyleID="s7Budget">
						<Data ss:Type="String"/>
					</Cell>
					<Cell ss:StyleID="s8Budget">
						<Data ss:Type="String">
							<xsl:value-of select="@remarks"/>
						</Data>
					</Cell>
				</Row>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
</xsl:stylesheet>